﻿# -*- coding: UTF-8 -*-
import urllib
import lxml.html as html

url_name = 'http://news.baidu.com/'
url_loc = 'E:/python/baidunews.html'
url_new = urllib.urlretrieve(url_name,filename=url_loc)
domtree = html.fromstring(open(url_loc,'r').read())
def rootsun(sun):
    x = 1
    for root in sun.iter('img'):
        x+=1
        print root.get('src')
        urllib.urlretrieve(root.get('src'),filename='E:/python/%s.png' % (x))

rootsun(domtree)